<!--
 * @Descripttion: 确定的弹窗
 * @version: 
 * @Author: lihk
 * @Date: 2024-01-02 16:38:25
 * @LastEditors: lihk
 * @LastEditTime: 2024-01-02 16:58:31
-->
<template>
  <div class="popup" v-show="visible">
    <div class="popup-mask"></div>
    <div :class="['popup-content', positionClass]">
      <div class="popup-title flex-cc">{{title}}</div>
      <div class="popup-btn flex">
        <span class="btn" @click="closePopup">取消</span>
        <span class="btn" @click="changePopup">确定</span>
      </div>
      <!-- 弹窗内容 -->
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    position: {
      type: String,
      default: 'center' // 默认居中位置
    },
    title: {
      type: String,
      default: ''
    }
  },
  computed: {
    positionClass () {
      return `popup-${this.position}`;
    }
  },
  methods: {
    closePopup () {
      this.$emit('close');
    }, 
    changePopup () {
      this.$emit('confirm');
    }
  }
}
</script>

<style lang='scss' scoped>
.popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.popup-mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
}

.popup-content {
  margin: 0 15px;
  background-color: #fff;
  width: 100%;
  // padding: 20px;
  border-radius: 10px;
  z-index: 999;
}

.popup-bottom {
  position: absolute;
  bottom: 0px;
  border-radius: 30px 30px 0px 0px;
  padding: 0;
}
.popup-btn {
  border-top: 1px solid #dacfb9;
  span {
    flex: 1;
    text-align: center;
    height: 44px;
    line-height: 44px;
    color: #d7ae3c;
    &:first-child {
      border-right: 1px solid #dacfb9;
    }
  }
}
.popup-title {
  margin: 20px;
}
</style>